/*
(function() {
    var slider = new fz.Scroll('.ui-slider', {
        role: 'slider',
        indicator: true,
        autoplay: true,
        interval: 3000
    });
    slider.on('beforeScrollStart', function(fromIndex, toIndex) {
        //console.log(fromIndex, toIndex)
    });
    slider.on('scrollEnd', function(cruPage) {
        //console.log(cruPage)
    });
})();
*/

//页面加载完毕
window.onload=function(){
    $data=$("div[id^='temp']").attr('id').substr(4).split('c');
    $ls="<img src='"+publicUrl+"/images/P_Details/"+$data[0]+"/p";
    $rs=".jpg' width='100%' height='100%' />"
    for(var i=1;i<=$data[1];i++){
        $('#li_ImgContent').prepend(
           $ls+i+$rs
            );
    }
    refreshVCount();
}


function acValuation(){
    if(d_valuation.style.display=="none"){
        $('#d_Details').hide();
        $('#d_valuation').show();
    }else
        $('#d_valuation').hide();
}

function acDetails(){
    if(d_Details.style.display=="none"){
        $('#d_valuation').hide();
        $('#d_Details').show();
    }else
        $('#d_Details').hide();
}

//加入购物车
function addCart(){
    var pCount=$('#pCount1').html();
    var pId=$('.isProId').attr('id').substr(3);
    var uId=1;
    $.post(handleUrl+"/Cart/addProToCart",{ProId:pId,ProCount:pCount,UserId:uId},
        function(response){
            if(response==33)
                tipMsg('商品库存不足!','warn');
            else{
                if(response>0){
                    tipMsg('添加成功!','success');
                }else{
                    tipMsg('添加失败!','info');
                }
            }
            
            $('.ui-dialog').addClass('show').hide();
        },'json'
    );
}

//立即结算
function nowPay(){
    var pCount=$('#pCount1').html();
    var pId=$('.isProId').attr('id').substr(3);
    var uId=1;
    $.post(handleUrl+"/Order/nowPay",{ProId:pId,ProCount:pCount,UserId:uId},
    function(response){
        if(response==33)
            tipMsg('商品库存不足!','info');
        else
        {
            if(response!=0){
                location.href=handleUrl+"/Payment/loadAddress/?OrderId="+response;
            }else{
                tipMsg('订单创建失败,请联系客服!','info');
            }            
        }
        
        $('.ui-dialog').addClass('show').hide();
    });
}

//显示加入购物车窗口
function showCartFrame(){
    $('.ui-dialog').addClass('show').show();
    aPrice.innerHTML=pPrice.innerHTML;
}

//商品数量增减，并更新数据
function countHandle(s,t){
    var c=parseFloat($('#pCount1').html());//获取商品个数
    var p=parseFloat($('#aPrice').html())/c;//计算商品单价
    if(s=='+')
        c+=1;
    else if(c>1)
        c-=1;
    $('#pCount1').html(c);
    $('#aPrice').html(parseFloat(p*c).toFixed(2));             
}

//顶部提示
function tipMsg($content,$type){
    var el;
    el=$.tips({
        content:$content,
        stayTime:2000,
        type:$type
    })
    
}

//刷新评论数
function refreshVCount(){
    $.post(handleUrl+"/Index/getVCount",{isProId:$('.isProId').attr('id').substr(3)},
        function(response){
            response=(response==null?0:response);
            p_VCount.innerHTML="累计评论："+response;
    },'json');
}

